//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#if _MSC_VER > 1000
#pragma once
#endif

#if !defined(__CKTFSDIRSTRENUMERATOR_H__)
#define __CKTFSDIRSTRENUMERATOR_H__

#define _NO_CKTFSDIRSTRENUMERATOR_CLASSOBJECT_
#include "_CKtfsDirStrEnumerator.h"
#include "CBasicDirectory.h"
#include "depend.h"

class CKtfsDirStrEnumerator : public _CKtfsDirStrEnumerator
{
public:
    CARAPI Current(
        /* [out] */ WStringBuf * pPsa);

    CARAPI MoveNext();

    CARAPI Reset();

    CKtfsDirStrEnumerator();

    CKtfsDirStrEnumerator(WString wcsPathName);

    ~CKtfsDirStrEnumerator();

    void *operator new(size_t size) { return ::operator new(size); }

    IBasicDirectory *m_pBasicDirectory;

private:
    // TODO: Add you private member variables here
    WChar *m_esPathName;
    Boolean m_bReset;
    Boolean m_bMove;
    WChar m_wcsFileName[_MAX_PATH];
    PVoid m_hFind;
};

inline CKtfsDirStrEnumerator::CKtfsDirStrEnumerator()
{
}

inline CKtfsDirStrEnumerator::CKtfsDirStrEnumerator(WString wcsPathName)
{
    m_esPathName = (WChar *)malloc(sizeof(WChar) * (wcslen(wcsPathName) + 1));
    if (m_esPathName == NULL) {
        return;
    }
    wcscpy(m_esPathName, wcsPathName);
    m_hFind = IO_INVALID_HANDLE_VALUE;
    m_bMove = FALSE;
    m_bReset = TRUE;
}

inline CKtfsDirStrEnumerator::~CKtfsDirStrEnumerator()
{
    if (m_esPathName) {
        free((void*) m_esPathName);
    }
    IO_FindClose(m_hFind);
}

#endif //!(__CDIRSTRENUMERATOR_H__)
